<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <h1>我是a页面</h1>
    <script>
      var str = window.location.search;
      // console.log(str);
      var res = str.substr(1);

      // 给一个规则的字符串 ，那么 s2o就会返还一个对象；
      // name=fdaf&age=fda&height=3232;
      function s2o(res) {
        var arr = res.split("&");
        //  console.log(arr);
        var obj = {};
        for (var i = 0; i < arr.length; i++) {
          // console.log(arr[i]);
          var strarr = arr[i].split("=");
          console.log(strarr);
          obj[strarr[0]] = strarr[1];
        }
        return obj;
      }
      console.log(s2o(res));
    </script>
  </body>
</html>
